<template>
  <div id="app">
    <div id="nav" v-show="scrollTop<=50">
      <div class="logo">
        <span>HeYuHang Blog</span>
      </div>
      <div class="li">
        <router-link to="/">Home</router-link>
        <router-link to="/tags">Tags</router-link>
        <router-link to="/videos">Videos</router-link>
        <router-link to="/about">About</router-link>
      </div>
    </div>
    <router-view/>
    <div class="footer">
        <span>鄂ICP备2021000514号-1</span>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      scrollTop:0
    }
  },
  mounted(){
    window.addEventListener('scroll',this.handleScroll,true)
  },
  methods:{
    handleScroll(e){      
      this.scrollTop = e.target.documentElement.scrollTop || e.target.body.scrollTop;  
    }, 
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#nav {
  padding: 20px 20px;
  display: flex;
  justify-content: space-between;
  width: 100%;
  position: fixed;
}
.logo span{
  font-weight: bold;
  color:  #42b983;
}
#nav .li{
  margin-right: 20px;
}
#nav a {
  font-weight: bold;
  text-decoration: none;
  padding: 20px;
  color: white;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
.footer{
  margin-top: 50px;
  height: 40px;
  text-align: center;
  font-size: 14px;
}
</style>
